<template>
  <div class="center-energy-report">
    <dv-loading v-if="loading"></dv-loading>
    <Aiseo
      v-else
      :lqtData="lqtData"
      :lqbData="lqbData"
      :ldbData="ldbData"
      :topitemdata="topitemdata"
    />
  </div>
</template>
<script>
import Aiseo from "../../components/aiseo/Aiseo";
import { topitemapi, lqtapi, lqbapi, ldbapi } from "../../api/base8090.js";
import { mapState } from "vuex";
export default {
  name: "aiseo",
  components: {
    Aiseo,
  },
  created() {
    this.timer = setInterval(() => {
      if (document.readyState === "complete") {
        this.loading = false;
        window.clearInterval(this.timer);
      }
    }, 1000);
    this.initData();
  },
  data() {
    return {
      loading: true,
      timer: null,
      topitemdata: {},
      lqtData: null,
      lqbData: null,
      ldbData: null,
      queryParmas: {
        stationCode: sessionStorage.getItem("stationCode"),
      },
    };
  },
  methods: {
    initData() {
      this.topitemdata = {};
      this.lqtData = null;
      this.lqbData = null;
      this.ldbData = null;
      //站厅 站台 外气 实时制冷量 数据
      topitemapi(this.queryParmas).then((res) => {
        this.topitemdata = res.data;
      });

      lqtapi(this.queryParmas).then((res) => {
        this.lqtData = res.data;
      });
      lqbapi(this.queryParmas).then((res) => {
        this.lqbData = res.data;
      });
      ldbapi(this.queryParmas).then((res) => {
        this.ldbData = res.data;
      });
    },
  },
  computed: {
    ...mapState(["stationCode"]),
  },
  watch: {
    stationCode(newVal, oldVal) {
      if (newVal != oldVal) {
        this.queryParmas.stationCode = newVal;
        this.initData();
      }
    },
  },
};
</script>
<style lang="less" scoped>
.center-energy-report {
  width: 100%;
  height: 100%;
}
</style>
